<?php
if (isset($_POST['n']) && isset($_POST['idc'])){
    include '../c/config.php';
    $ziDian=array('loo','llo','lll','olo','ool','olo','olo');
    $randId=rand(0,5);
    
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $dbhost.$mysqli->error);}
    $name=addslashes(trim($_POST['n'])); 
    $idc=addslashes(trim($_POST['idc']));
    if(strpos($name,'.') !== false){
        $name=str_replace('.', '·', $name);
    }
    $queryJ=$mysqli->query("SELECT id,islock from `uinfo_sim` where name='".$name."' and idcard='".$idc."'  limit 0,1 ");
    if($queryJ->num_rows>0){
        $getidD=$queryJ->fetch_assoc();
        
        if('y' == $getidD['islock']){
            echo json_encode(array('s'=>'l'));
            exit;
        }
        
        $idFile='../data/user/'.$getidD['id'].'.txt';
        if (file_exists($idFile)){
            $getU=json_decode(file_get_contents($idFile),true);
        }else{
            $query=$mysqli->query("SELECT * from `uinfo` where id=".$getidD['id']." limit 0,1 ");
            $getU=$query->fetch_assoc();
        }
        $getU['vt']=$ziDian[$randId].$getU['id'];
        $getU['id']=rand(1,36);
        echo json_encode(array('s'=>'y','u'=>$getU));
    }else{
        echo json_encode(array('s'=>'n'));
    }
    $mysqli->close();
    exit;
}
